package com.goodving.guli.fragment;

import android.animation.Animator;
import android.app.Activity;
import android.app.DialogFragment;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.activity.RecordWeightActivity;
import com.goodving.guli.activity.StatisticActivity;
import com.goodving.guli.activity.SystemBarTintActivity;
import com.goodving.guli.activity.WeightGoalSetActivity;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C0708b;
import com.goodving.guli.bt.C1154e;
import com.goodving.guli.bt.DimPanelFragment;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.dataprocess.DaySportData;
import com.goodving.guli.bt.dataprocess.DaySportData.Summary;
import com.goodving.guli.bt.dataprocess.SportDay;
import com.goodving.guli.bt.eventbus.EventUserChanged;
import com.goodving.guli.bt.eventbus.EventUserPicked;
import com.goodving.guli.bt.eventbus.EventWeightChanged;
import com.goodving.guli.bt.eventbus.EventWeightSyncedDevice;
import com.goodving.guli.bt.eventbus.EventWeightSyncedServer;
import com.goodving.guli.bt.eventbus.EventWeightWithUser;
import com.goodving.guli.bt.model.Birthday;
import com.goodving.guli.bt.model.C1634i;
import com.goodving.guli.bt.model.DataManager;
import com.goodving.guli.bt.model.HwSyncDataStatus;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.model.ShareData;
import com.goodving.guli.bt.model.WeightInfo;
import com.goodving.guli.bt.model.WeightInfoManager;
import com.goodving.guli.bt.profile.scale.C3843c;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.HwConnStatus;
import com.goodving.guli.bt.profile.scale.ScaleWeightInfo;
import com.goodving.guli.bt.ui.C1795p;
import com.goodving.guli.bt.ui.WeightUserQuickPicker;
import com.goodving.guli.bt.ui.ab;
import com.goodving.guli.bt.utils.C0893f;
import com.goodving.guli.bt.utils.WeightUtil;
import com.goodving.guli.bt.weight.LuaUtil;
import com.goodving.guli.bt.weight.UserInfo;
import com.goodving.guli.bt.weight.UserInfoManager;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.server.ClientDataConstants;
import com.goodving.guli.view.C0804t;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;

import cn.com.smartdevices.bracelet.chart.C0738L;
import cn.com.smartdevices.bracelet.chart.StatisticChart;
import cn.com.smartdevices.bracelet.chart.StatisticChartView;
import cn.com.smartdevices.bracelet.chart.base.BarChart;
import cn.com.smartdevices.bracelet.chart.data.AsyncChartDataLoader;
import cn.com.smartdevices.bracelet.chart.data.ChartDataLoader;
import cn.com.smartdevices.bracelet.chart.data.ItemData;
import cn.com.smartdevices.bracelet.chart.util.AnimUtil;
import cn.com.smartdevices.bracelet.chart.util.C0800p;
import cn.com.smartdevices.bracelet.chart.util.C0801q;
import cn.com.smartdevices.bracelet.chart.util.ChartData;
import cn.com.smartdevices.bracelet.chart.util.DynamicData;
import de.greenrobot.event.EventBus;


/**
 * Created by john on 2015/12/7.
 */
public class StatisticFragment extends C1795p implements View.OnClickListener {
    private static final String f9343c = "Statistic.Main";
    private static final int f9344d = 1;
    private static final int f9345e = 16;
    private static final int f9346f = 256;
    private static final int f9347g = 11;
    private static final int f9348h = 7;
    private static final int f9349i = 5;
    private static final int f9350j = 7;
    private static final int f9351k = 15;
    private static final int f9352l = 35;
    private static final int f9353m = 1;
    private static final int f9354n = 2;
    private static final int f9355o = 3;
    private static final int f9356p = 1;
    private static final int f9357q = 16;
    private WeightInfoManager f9358A;
    private UserInfoManager f9359B;
    private int f9360C;
    private WeightUserQuickPicker f9361D;
    private int f9362E;
    private WeightInfo f9363F;
    private int f9364G;
    private boolean f9365H;
    private int f9366I;
    private int f9367J;
    private int f9368K;
    private int f9369L;
    private int f9370M;
    private BarChart.BarItem f9371N; // C0726c
    private fa f9372O;
    private SparseArray<fa> f9373P;
    private ChartDataLoader.LoadCallback f9374Q;
    private SparseArray<ChartDataLoader> f9375R;
    private boolean f9376S;
    private boolean f9377T;
    private String f9378U;
    private String f9379V;
    private String f9380W;
    private HashMap<String, DaySportData.Summary> f9381X;
    private SparseArray<WeightInfo> f9382Y;
    private View f9383Z;
    private int aA;
    private boolean aB;
    private int aC;
//    private C1693p aD;
    private boolean aE;
    private int aF;
    private String aG;
    private boolean aH;
    private TextView aa;
    private TextView ab;
    private View ac;
    private View ad;
    private StatisticChartView ae;
    private StatisticChartView af;
    private StatisticChartView ag;
    private ImageButton ah;
    private ImageButton ai;
    private ImageButton aj;
    private View ak;
    private View al;
    private SparseArray<View> am;
    private SparseArray<View> an;
    private SparseArray<View> ao;
    private View ap;
    private View aq;
    private int ar;
    private int as;
    private int at;
    private Animator au;
    private Animator av;
    private Animator aw;
    private boolean ax;
    private boolean ay;
    private SportDay az;
    public StatisticChartView f9384b;
    private int f9385r;
    private int f9386s;
    private DataManager f9387t;
    private SportDay f9388u;
    private SportDay f9389v;
    private SportDay f9390w;
    private SportDay f9391x;
    private SportDay f9392y;
    private SportDay f9393z;

    public StatisticFragment() {
        this.f9364G = f9350j;
        this.ai = null;
        this.aj = null;
        this.aC = f9355o;
//        this.aD = null;
        this.aE = false;
        this.aF = C3843c.MILI.m25103b();
    }

    class eX implements Animator.AnimatorListener {
        final /* synthetic */ long f10067a;
        final /* synthetic */ StatisticFragment f10068b;

        eX(StatisticFragment statisticFragment, long j) {
            this.f10068b = statisticFragment;
            this.f10067a = j;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10068b.ae.m8545a(this.f10068b.f9385r);
            this.f10068b.af.m8545a(this.f10068b.f9385r);
            Animator a = this.f10068b.f9384b.m8540a();
            a.setDuration(this.f10067a / 2);
            a.setInterpolator(new DecelerateInterpolator(C4220a.bg));
            a.start();
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
        }
    }

    class eY implements C0800p {
        final /* synthetic */ StatisticFragment f10069a;

        eY(StatisticFragment statisticFragment) {
            this.f10069a = statisticFragment;
        }

        public void m8763a (int i) { // m14736a
            Activity activity = this.f10069a.getActivity();
            if (activity != null) {
                ((SystemBarTintActivity) activity).applyStatusBarTint(i);
            }
        }
    }

    class eL implements Animator.AnimatorListener {
        final /* synthetic */ StatisticFragment f10049a;

        eL(StatisticFragment statisticFragment) {
            this.f10049a = statisticFragment;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10049a.ae.m8399d(true);
            this.f10049a.af.m8399d(true);
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
        }
    }

    private Animator m14133a(int i, int i2, long j) {
        Animator b = this.f9384b.m8547b(j / 2, -2.0f, -2.0f);
        b.addListener(new eX(this, j));
        b.setInterpolator(new AccelerateInterpolator(C4220a.bg));
        C0801q.m8765a(b);
        C0800p eYVar = new eY(this);
        View[] viewArr = new View[f9354n];
        viewArr[0] = this.f9383Z;
        viewArr[f9356p] = (View) this.f9384b.getParent();
        C0801q.m8770b(AnimUtil.m8741a(i, i2, eYVar, viewArr), (j / 3) * 2);
        b = C0801q.m8764a();
        b.addListener(new eL(this));
        return b;
    }

    class eM implements Animator.AnimatorListener {
        final /* synthetic */ StatisticChartView f10050a;
        final /* synthetic */ StatisticChartView f10051b;
        final /* synthetic */ StatisticFragment f10052c;

        eM(StatisticFragment statisticFragment, StatisticChartView statisticChartView, StatisticChartView statisticChartView2) {
            this.f10052c = statisticFragment;
            this.f10050a = statisticChartView;
            this.f10051b = statisticChartView2;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            GuliLog.tracePrintInfo("Statistic.Main", "OUT VIEW : " + this.f10051b);
            this.f10051b.setVisibility(View.INVISIBLE);
            this.f10051b.setAlpha(1.0f);
            this.f10051b.setScaleX(1.0f);
            if (this.f10052c.f9386s != 1) {
                this.f10052c.ak.setEnabled(true);
            }
            if (this.f10052c.f9386s != PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                this.f10052c.al.setEnabled(true);
            }
            this.f10052c.ae.m8399d(true);
            this.f10052c.af.m8399d(true);
            this.f10052c.ax = false;
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            GuliLog.tracePrintInfo("Statistic.Main", "IN VIEW : " + this.f10050a);
            this.f10050a.setVisibility(View.VISIBLE);
            if (this.f10052c.f9371N != null) {
                this.f10052c.f9371N.f3886e = false;
            }
            this.f10051b.m8552c();
        }
    }

    private Animator m14134a(StatisticChartView statisticChartView, StatisticChartView statisticChartView2, int i, int i2, int i3, int i4, int i5) {
        Animator b = AnimUtil.m8758b((View) statisticChartView, ((float) i) / ((float) i2), 1.0f);
        Animator b2 = AnimUtil.m8758b((View) statisticChartView2, 1.0f, ((float) i2) / ((float) i));
        Animator a = AnimUtil.m8746a((View) statisticChartView2, 1.0f, 0.0f);
        C0801q.m8766a(b, (long) i5);
        C0801q.m8770b(b2, (long) i5);
        C0801q.m8770b(a, (long) i5);
        C0801q.m8769b(statisticChartView.m8542a((long) i5, (float) i3, (float) i4));
        b = C0801q.m8764a();
        b.setInterpolator(new AccelerateDecelerateInterpolator());
        b.addListener(new eM(this, statisticChartView, statisticChartView2));
        return b;
    }

    protected static String m14139a(long j) {
        String str = C3657a.f18328f;
        return DateFormat.format(C0893f.m9087a(Boolean.valueOf(m14158a(-1, j)), j), j).toString();
    }

    private void m14140a(int i, int i2, int i3, int i4, boolean z) {
        String str;
        View view = null;
        View view2 = i == f9357q ? (View) this.am.get(i3) : i == f9356p ? (View) this.an.get(i3) : i == f9346f ? (View) this.ao.get(i3) : null;
        String str2 = C3657a.f18328f;
        if (i2 == f9357q) {
            view = (View) this.am.get(i4);
            str = C0668a.cN;
        } else if (i2 == f9356p) {
            view = (View) this.an.get(i4);
            str = C0668a.cM;
        } else if (i2 == f9346f) {
            view = (View) this.ao.get(i4);
            str = str2;
        } else {
            str = str2;
        }
        switch (i4) {
            case f9356p /*1*/:
                this.al.setEnabled(true);
                this.ak.setEnabled(false);
                C0668a.m8129a(getActivity(), str, "Level", C0668a.cX);
                break;
            case f9357q /*16*/:
                this.al.setEnabled(true);
                this.ak.setEnabled(true);
                C0668a.m8129a(getActivity(), str, "Level", C0668a.cY);
                break;
            case f9346f /*256*/:
                this.al.setEnabled(false);
                this.ak.setEnabled(true);
                C0668a.m8129a(getActivity(), str, "Level", C0668a.cZ);
                break;
        }
        this.f9372O = (fa) this.f9373P.get(i4);
        this.aq = view2;
        this.ap = view;
        m14148a(this.f9384b, this.f9374Q, i4);
        m14147a(this.f9384b, i4);
    }

    private void m14141a(int i, int i2, boolean z) {
        m14140a(this.f9385r, this.f9385r, i, i2, z);
    }

    private void m14142a(int i, ChartDataLoader.LoadCallback c0731f, SparseArray<ChartDataLoader> sparseArray) {
        AsyncChartDataLoader c0747a = new AsyncChartDataLoader();
        c0747a.setLoadCallback(c0731f);
        sparseArray.put(i, c0747a);
    }

    private void m14143a(int i, boolean z) {
        int i2;
        int i3 = 0;
        if (i == f9357q) {
            this.ah.setVisibility(View.VISIBLE);
            this.ai.setVisibility(View.GONE);
            this.aj.setVisibility(View.GONE);
            this.ah.setImageResource(R.drawable.btn_dynamic_mode_step);
            i2 = this.as;
            i3 = i2;
            i2 = this.ar;
        } else if (i == f9356p) {
            this.ah.setVisibility(View.VISIBLE);
            this.ai.setVisibility(View.GONE);
            this.aj.setVisibility(View.GONE);
            this.ah.setImageResource(R.drawable.btn_dynamic_mode_sleep);
            i2 = this.ar;
            i3 = i2;
            i2 = this.as;
        } else if (i == f9346f) {
            this.ah.setVisibility(View.GONE);
            this.aj.setVisibility(View.VISIBLE);
            this.ah.setImageResource(R.drawable.btn_statistic_mode_weight_modify);
            i2 = this.as;
            i3 = i2;
            i2 = this.at;
        } else {
            i2 = 0;
        }
        if (z) {
            this.f9383Z.setBackgroundColor(i2);
            ((View) this.f9384b.getParent()).setBackgroundColor(i2);
            ((SystemBarTintActivity) getActivity()).applyStatusBarTint(i2);
            this.ae.m8545a(i);
            if (this.af != null) {
                this.af.m8545a(i);
            }
        } else {
            this.au = m14133a(i3, i2, 650);
            this.au.start();
        }
        if (i != f9346f) {
            m14155a(this.f9390w);
        }
    }

    private void m14144a(long j, boolean z) {
        m14156a(null, j, z);
    }




    class eR implements ab {
        final /* synthetic */ StatisticFragment f10060a;

        eR(StatisticFragment statisticFragment) {
            this.f10060a = statisticFragment;
        }

        public void m14727a (View view, UserInfo userInfo, int i) { // m14728a
            if (userInfo == null) {
                this.f10060a.m14179d(1);
            } else if (this.f10060a.f9362E != userInfo.uid && !this.f10060a.f9365H) {
                this.f10060a.f9365H = true;
                this.f10060a.f9361D.m15379a(i);
                this.f10060a.m14182e(userInfo.uid);
            }
        }
    }

    class eQ implements View.OnClickListener {
        final /* synthetic */ StatisticFragment f10059a;

        eQ(StatisticFragment statisticFragment) {
            this.f10059a = statisticFragment;
        }

        public void onClick(View view) {
        }
    }

    private void m14145a(View view) {
        this.f9383Z = view.findViewById(R.id.header);
        this.aa = (TextView) view.findViewById(R.id.header_sync_tip);
        this.ab = (TextView) view.findViewById(R.id.header_sub_title);
        this.ac = view.findViewById(R.id.share);
        this.ac.setOnClickListener(this);
        this.ad = view.findViewById(R.id.add_member);
        this.ad.setOnClickListener(this);
        this.ae = (StatisticChartView) view.findViewById(R.id.statistic_chart);
        this.af = (StatisticChartView) view.findViewById(R.id.next_statistic_chart);
        this.ah = (ImageButton) view.findViewById(R.id.mode_switch);
        this.ah.setOnClickListener(this);
        this.ai = (ImageButton) view.findViewById(R.id.weight_report_edit_btn);
        this.ai.setOnClickListener(this);
        this.aj = (ImageButton) view.findViewById(R.id.weight_report_dele_btn);
        this.aj.setOnClickListener(this);
        this.al = view.findViewById(R.id.mode_statistic_zoom_in);
        this.ak = view.findViewById(R.id.mode_statistic_zoom_out);
        this.al.setOnClickListener(this);
        this.ak.setOnClickListener(this);
        if ((this.aC & f9356p) == 0) {
            this.ah.setVisibility(View.GONE);
        }
        if (this.f9385r == f9346f) {
            View findViewById = view.findViewById(R.id.info_weight_layout);
            this.ao = new SparseArray(f9355o);
            this.ao.put(f9356p, findViewById);
            this.ao.put(f9357q, findViewById);
            this.ao.put(f9346f, findViewById);
            m14178d();
            this.f9361D = (WeightUserQuickPicker) view.findViewById(R.id.user_picker);
            this.f9361D.setVisibility(View.VISIBLE);
            this.f9361D.setOnClickListener(new eQ(this));
            this.f9361D.m15381a(new eR(this));
            this.f9361D.m15382a(this.f9359B.m15598d());
            if (this.f9362E != -1) {
                this.f9361D.m15385b(this.f9362E);
            }
            this.aj.setVisibility(View.VISIBLE);
            this.ah.setVisibility(View.GONE);
            if (this.f9360C == 0) {
                this.aj.setEnabled(false);
                this.ai.setEnabled(false);
                return;
            } else if (ChartData.m8731a().m8816t() == -1 && this.f9360C == f9356p) {
                this.aj.setEnabled(false);
                this.ai.setEnabled(false);
                return;
            } else {
                this.aj.setEnabled(true);
                this.ai.setEnabled(true);
                return;
            }
        }
        this.aj.setVisibility(View.GONE);
        this.ai.setVisibility(View.GONE);
        this.ah.setVisibility(View.VISIBLE);
//        findViewById = view.findViewById(R.id.info_sleep_daily_layout);
//        View findViewById2 = view.findViewById(R.id.info_sleep_weekly_layout);
//        View findViewById3 = view.findViewById(R.id.info_sleep_monthly_layout);
//        View findViewById4 = view.findViewById(R.id.info_step_daily_layout);
//        View findViewById5 = view.findViewById(R.id.info_step_weekly_layout);
//        View findViewById6 = view.findViewById(R.id.info_step_monthly_layout);
        this.am = new SparseArray(f9355o);
        this.an = new SparseArray(f9355o);
//        this.am.put(f9356p, findViewById);
//        this.am.put(f9357q, findViewById2);
//        this.am.put(f9346f, findViewById3);
//        this.an.put(f9356p, findViewById4);
//        this.an.put(f9357q, findViewById5);
//        this.an.put(f9346f, findViewById6);
        m14181e();
    }

    private void m14146a(View view, int i) {
        WeightInfo f = this.f9358A.m15779f(i);
        if (f != null) {
            this.ae.m8544a(f.weight);
        }
        UserInfo a = this.f9359B.getInfoByUid(i);
        if (a != null) {
            this.ae.m8549b(a.targetWeight);
            m14167b(a.name);
        }
    }

    private void m14147a(StatisticChartView statisticChartView, int i) {
        switch (i) {
            case f9356p /*1*/:
                if (this.f9385r == f9346f) {
                    statisticChartView.m8553c(this.f9364G);
                } else {
                    statisticChartView.m8553c((int) f9347g);
                }
            case f9357q /*16*/:
                statisticChartView.m8553c((int) f9350j);
            case f9346f /*256*/:
                statisticChartView.m8553c((int) f9349i);
            default:
        }
    }

    private void m14148a(StatisticChartView statisticChartView, ChartDataLoader.LoadCallback c0731f, int i) {
        ChartDataLoader c0746d = (ChartDataLoader) this.f9375R.get(i);
        c0746d.setLoadCallback(c0731f);
        statisticChartView.m8546a(c0746d);
    }

    private void m14152a(WeightInfo weightInfo) {
        WeightUtil.deleteWeightInfoMarkFully(weightInfo);
        m14221u();
        EventBus eventBus = EventBus.getDefault();
        int[] iArr = new int[f9356p];
        iArr[0] = weightInfo.uid;
        eventBus.post(new EventWeightChanged(iArr));
    }

    private void m14153a(WeightInfo weightInfo, int i) {
        this.f9358A.m15750a(weightInfo, i);
        m14221u();
        GuliLog.tracePrintInfo(f9343c, "fromUID " + weightInfo.uid + " toUID " + i);
        GuliLog.tracePrintInfo(f9343c, "timestamp " + weightInfo.timestamp);
        GuliLog.tracePrintInfo(f9343c, "value in kg" + weightInfo.weight);
        GuliLog.tracePrintInfo(f9343c, "toUser height " + UserInfoManager.getInstance().getInfoByUid(i).height);
        UserInfo a = UserInfoManager.getInstance().getInfoByUid(weightInfo.uid);
        UserInfo a2 = UserInfoManager.getInstance().getInfoByUid(i);
        float a3 = WeightUtil.m15693a(a.height, Birthday.fromStr(a.birthday).getAge(), weightInfo.weight);
        ScaleWeightInfo c3925e = new ScaleWeightInfo();
        c3925e.m25488b(WeightUtil.m15716c(WeightUtil.m15706b(weightInfo.weight, Keeper.readPersonInfo().miliConfig.weightUnit), f9356p));
        c3925e.m25482a(a3);
        c3925e.setUnitType(Keeper.readPersonInfo().miliConfig.weightUnit);
        c3925e.setDate(weightInfo.timestamp);
        LuaUtil.getInstance(getActivity()).m15961a(c3925e, a2, WeightUtil.m15696a(weightInfo.timestamp, weightInfo.uid));
        EventBus eventBus = EventBus.getDefault();
        int[] iArr = new int[f9354n];
        iArr[0] = weightInfo.uid;
        iArr[f9356p] = i;
        eventBus.post(new EventWeightChanged(iArr));
    }

    private void m14154a(HwSyncDataStatus hwSyncDataStatus) {
        GuliLog.tracePrintInfo(f9343c, "Current Sync Status : " + hwSyncDataStatus + ",type = " + hwSyncDataStatus.m25421h());
        if (this.f9385r != f9346f && this.aF == hwSyncDataStatus.m25421h().m25103b()) {
            TextView textView;
            Object[] objArr;
            if (hwSyncDataStatus.m25415b()) {
                textView = this.aa;
                objArr = new Object[f9356p];
                objArr[0] = Integer.valueOf(0);
                textView.setText(getString(R.string.dynamic_tip_sync_progress, objArr));
            } else if (hwSyncDataStatus.m25416c()) {
                textView = this.aa;
                objArr = new Object[f9356p];
                objArr[0] = Integer.valueOf(hwSyncDataStatus.m25419f());
                textView.setText(getString(R.string.dynamic_tip_sync_progress, objArr));
            } else {
                this.aa.setText(Utils.m7977a(getActivity(), (int) R.string.dynamic_tip_sync_time, this.aF));
            }
        }
    }

    private void m14155a(SportDay sportDay) {
        m14156a(sportDay, 0, false);
    }

    private void m14156a(SportDay sportDay, long j, boolean z) {
        String str = null;
        Object[] objArr;
        if (this.f9385r == f9357q) {
            if (this.f9372O != null) {
                str = this.f9378U;
                objArr = new Object[f9356p];
                objArr[0] = this.f9372O.m14815a(sportDay);
                str = String.format(str, objArr);
            }
        } else if (this.f9385r == f9356p) {
            if (this.f9372O != null) {
                str = this.f9379V;
                objArr = new Object[f9356p];
                objArr[0] = this.f9372O.m14815a(sportDay);
                str = String.format(str, objArr);
            }
        } else if (this.f9385r == f9346f && this.f9372O != null) {
            CharSequence format = DateFormat.format(C0893f.m9087a(Boolean.valueOf(z), j), j);
            String str2 = this.f9380W;
            Object[] objArr2 = new Object[f9356p];
            objArr2[0] = format;
            str = String.format(str2, objArr2);
        }
        m13557a(str);
        if ((this.f9386s == f9356p && sportDay.equals(this.f9388u)) || ((this.f9386s == f9357q && sportDay.offsetWeek(this.f9388u) == 0) || (this.f9386s == f9346f && sportDay.offsetMonth(this.f9388u) == 0))) {
            ((View) this.aa.getParent()).setVisibility(View.VISIBLE);
        } else {
            ((View) this.aa.getParent()).setVisibility(View.GONE);
        }
    }

    private void m14157a(boolean z, int i) {
        this.f9376S = true;
        ChartDataLoader m = this.f9384b.getDataLoader();
        m.cancel();
        if (z) {
            m.clearData();
            this.f9384b.m8556e();
        }
        this.f9384b.setScrollable(true);
        this.f9384b.m8555d(i);
        if (i != 0) {
            this.f9384b.m8559f(i);
        }
    }

    protected static boolean m14158a(long j, long j2) {
        Calendar instance;
        Calendar instance2;
        if (j < 0) {
            instance = Calendar.getInstance();
            instance2 = Calendar.getInstance();
            instance2.setTimeInMillis(j2);
            return instance.get(Calendar.YEAR) != instance2.get(Calendar.YEAR);
        } else {
            instance = Calendar.getInstance();
            instance.setTimeInMillis(j);
            instance2 = Calendar.getInstance();
            instance2.setTimeInMillis(j2);
            return instance.get(Calendar.YEAR) != instance2.get(Calendar.YEAR);
        }
    }

    private Animator m14160b(StatisticChartView statisticChartView, StatisticChartView statisticChartView2, int i, int i2, int i3, int i4, int i5) {
        float f = ((float) i) / ((float) i2);
        Animator a = AnimUtil.m8746a((View) statisticChartView, 0.0f, 1.0f);
        Animator b = AnimUtil.m8758b((View) statisticChartView, f, 1.0f);
        Animator b2 = AnimUtil.m8758b((View) statisticChartView2, 1.0f, ((float) i2) / ((float) i));
        C0801q.m8766a(b, (long) i5);
        C0801q.m8770b(a, (long) i5);
        C0801q.m8770b(b2, (long) i5);
        C0801q.m8769b(statisticChartView2.m8547b((long) i5, (float) i3, (float) i4));
        b = C0801q.m8764a();
        b.setInterpolator(new AccelerateDecelerateInterpolator());
        b.addListener(new eN(this, statisticChartView, statisticChartView2));
        return b;
    }

    class eN implements Animator.AnimatorListener {
        final /* synthetic */ StatisticChartView f10053a;
        final /* synthetic */ StatisticChartView f10054b;
        final /* synthetic */ StatisticFragment f10055c;

        eN(StatisticFragment statisticFragment, StatisticChartView statisticChartView, StatisticChartView statisticChartView2) {
            this.f10055c = statisticFragment;
            this.f10053a = statisticChartView;
            this.f10054b = statisticChartView2;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            GuliLog.tracePrintInfo("Statistic.Main", "OUT VIEW : " + this.f10054b);
            this.f10054b.setVisibility(View.INVISIBLE);
            this.f10054b.setAlpha(1.0f);
            this.f10054b.setScaleX(1.0f);
            if (this.f10055c.f9386s != 1) {
                this.f10055c.ak.setEnabled(true);
            }
            if (this.f10055c.f9386s != PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                this.f10055c.al.setEnabled(true);
            }
            this.f10055c.ae.m8399d(true);
            this.f10055c.af.m8399d(true);
            this.f10055c.ax = false;
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            GuliLog.tracePrintInfo("Statistic.Main", "IN VIEW : " + this.f10053a);
            this.f10053a.setVisibility(View.VISIBLE);
            this.f10053a.m8552c();
        }
    }

    private void m14165b(int i, boolean z) {
        m14140a(this.f9385r, this.f9385r, i, i, z);
    }

    private void m14167b(String str) {
        String str2 = this.f9380W;
        Object[] objArr = new Object[f9356p];
        objArr[0] = C3657a.f18328f;
        m13557a(String.format(str2, objArr));
        this.ab.setText(str);
    }

    private void m14172c(int i) {
        m14157a(true, i);
    }

    private boolean m14174c() {
        return this.aF != C3843c.SHOES.m25103b() && ChartData.m8731a().m8820x();
    }

    private void m14178d() {
        AnimUtil.m8754a((ViewGroup) this.ao.get(f9356p));
        AnimUtil.m8754a((ViewGroup) this.ao.get(f9357q));
        AnimUtil.m8754a((ViewGroup) this.ao.get(f9346f));
    }

    private void m14179d(int i) {
    }

    private void m14181e() {
        AnimUtil.m8754a((ViewGroup) this.am.get(f9356p));
        AnimUtil.m8754a((ViewGroup) this.am.get(f9357q));
        AnimUtil.m8754a((ViewGroup) this.am.get(f9346f));
        AnimUtil.m8754a((ViewGroup) this.an.get(f9356p));
        AnimUtil.m8754a((ViewGroup) this.an.get(f9357q));
        AnimUtil.m8754a((ViewGroup) this.an.get(f9346f));
    }

    class eP implements Runnable {
        final /* synthetic */ int f10057a;
        final /* synthetic */ StatisticFragment f10058b;

        eP(StatisticFragment statisticFragment, int i) {
            this.f10058b = statisticFragment;
            this.f10057a = i;
        }

        public void run() {
            this.f10058b.f9362E = this.f10057a;
            this.f10058b.f9363F = null;
            this.f10058b.f9368K = 0;
            this.f10058b.m14146a(this.f10058b.f9361D, this.f10058b.f9362E);
            this.f10058b.m14221u();
        }
    }

    private void m14182e(int i) {
        Animator b = this.f9384b.m8547b(220, C0804t.m8825a(getActivity(), 185.0f), -1);
        b.setInterpolator(new AccelerateInterpolator());
        b.start();
        this.f9384b.postDelayed(new eP(this, i), b.getDuration() + 50);
        EventBus.getDefault().post(new EventUserChanged(i));
    }

    class eT implements Animator.AnimatorListener {
        final /* synthetic */ eS f10062a;

        eT(eS eSVar) {
            this.f10062a = eSVar;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f10062a.f10061a.aw.setStartDelay(0);
            this.f10062a.f10061a.f9365H = false;
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f10062a.f10061a.f9384b.setScrollable(false);
        }
    }

    abstract class fa {
        protected int f10167a;
        protected int f10168b;
        protected int f10169c;
        protected int f10170d;
        protected int f10171e;
        protected int f10172f;
        protected int f10173g;
        protected int f10174h;
        protected int f10175i;
        protected int f10176j;
        protected int f10177k;
        protected int f10178l;
        protected int f10179m;
        protected int f10180n;
        protected int f10181o;
        protected float f10182p;
        protected int f10183q;
        protected int f10184r;
        protected int f10185s;
        protected int f10186t;
        final /* synthetic */ StatisticFragment f10187u;

        private fa(StatisticFragment statisticFragment) {
            this.f10187u = statisticFragment;
        }

        protected int m14811a(long j) {
            Calendar instance = Calendar.getInstance();
            instance.setTimeInMillis(j);
            return instance.get(Calendar.MINUTE) + (instance.get(Calendar.HOUR_OF_DAY) * 60);
        }

        protected abstract C0738L m14812a(int i);

        protected C0738L m14813a(int i, int i2, int i3, int i4, float f, int i5, int i6, int i7) {
            C0738L c0738l = new C0738L();
            if (i5 > 0) {
                c0738l.f3898a = i / i5;
            }
            if (i6 > 0) {
                c0738l.f3900c = i3 / i6;
                c0738l.f3901d = i4 / i6;
            }
            if (i7 > 0) {
                c0738l.f3902e = f / ((float) i7);
            }
            return c0738l;
        }

        protected abstract ShareData m14814a(SportDay sportDay, int i);

        protected abstract String m14815a(SportDay sportDay);

        protected void m14816a() {
            this.f10167a = 0;
            this.f10168b = 0;
            this.f10169c = 0;
            this.f10170d = 0;
            this.f10171e = 0;
            this.f10172f = 0;
            this.f10173g = 0;
            this.f10174h = 0;
            this.f10175i = 0;
            this.f10176j = 0;
            this.f10177k = 0;
            this.f10178l = 0;
            this.f10179m = 0;
            this.f10180n = 0;
            this.f10181o = 0;
            this.f10182p = 0.0f;
            this.f10183q = 0;
            this.f10184r = 0;
            this.f10185s = 0;
            this.f10186t = 0;
            this.f10187u.az = null;
            this.f10187u.aA = 0;
        }

        protected void m14817a(int i, ShareData shareData, SportDay sportDay) {
            shareData.setType(2);
            int i2 = R.string.share_sleep_description;
            switch (i) {
                case 1 /*1*/:
                    shareData.setType(2);
                    break;
                case 16 /*16*/:
                    shareData.setType(3);
                    i2 = R.string.share_sleep_description_average;
                    break;
                case PersonInfo.INCOMING_CALL_DISABLE_BIT /*256*/:
                    shareData.setType(4);
                    i2 = R.string.share_sleep_description_average;
                    break;
            }
            if (this.f10184r == 0) {
                this.f10184r = 1;
            }
            shareData.content = (this.f10176j / this.f10185s) + C3657a.f18328f;
            shareData.time = Utils.m8058d(this.f10187u.f9390w);
            int i3 = this.f10177k / this.f10185s;
            int i4 = this.f10178l / this.f10185s;
            String a = C0893f.m9085a(this.f10179m / this.f10185s);
            String a2 = C0893f.m9085a(this.f10180n / this.f10185s);
            shareData.description = this.f10187u.getString(i2, new Object[]{Integer.valueOf(i3 / 60), Integer.valueOf(i3 % 60), Integer.valueOf(i4 / 60), Integer.valueOf(i4 % 60), a, a2});
        }

        protected void m14818a(View view) {
            View findViewById = view.findViewById(R.id.info_sleep);
            View findViewById2 = view.findViewById(R.id.info_sleep_deep);
            View findViewById3 = view.findViewById(R.id.info_sleep_shallow);
            TextView textView = (TextView) view.findViewById(R.id.info_sleep_time);
            TextView textView2 = (TextView) view.findViewById(R.id.info_sleep_rise_time);
            View findViewById4 = view.findViewById(R.id.info_sleep_wake);
            if (this.f10185s == 0) {
                this.f10185s = 1;
            }
            ChartData.m8734a(findViewById, this.f10176j / this.f10185s, this.f10187u.getActivity());
            ChartData.m8734a(findViewById2, this.f10177k / this.f10185s, this.f10187u.getActivity());
            ChartData.m8734a(findViewById3, this.f10178l / this.f10185s, this.f10187u.getActivity());
            int i = this.f10179m / this.f10185s;
            if (i < 0) {
                i += DaySportData.DAY_SPORT_LEN;
            }
            textView.setText(C0893f.m9085a(i));
            int i2 = this.f10180n / this.f10185s;
            if (i2 < 0) {
                i2 += DaySportData.DAY_SPORT_LEN;
            }
            textView2.setText(C0893f.m9085a(i2));
            ChartData.m8734a(findViewById4, this.f10181o / this.f10185s, this.f10187u.getActivity());
        }

        protected void m14819a(WeightInfo weightInfo) {
            this.f10182p += weightInfo.weight;
        }

        protected void m14820a(DaySportData.Summary summary) {
            this.f10176j += summary.getSleep();
            this.f10177k += summary.getSleepDeepTime();
            this.f10178l += summary.getSleepShallowTime();
            int a = Utils.m7965a(summary);
            this.f10179m += a;
            this.f10180n = (a + Utils.m8029b(summary)) + this.f10180n;
            this.f10181o += summary.getSleepWakeTime();
        }

        protected void m14821a(SportDay sportDay, DaySportData.Summary summary, C1634i c1634i) {
            int c;
            int d;
            int i = 0;
            if (this.f10187u.m14174c() && sportDay.equals(this.f10187u.f9388u)) {
                DynamicData a = ChartData.m8731a();
                c = a.m8787c();
                d = a.m8791d();
                i = a.m8797f();
            } else {
                d = 0;
                c = 0;
            }
            if (c <= 0) {
                c = summary.getSteps();
                d = summary.getStepDistance();
                i = summary.getStepCalories();
            }
            this.f10167a = c + this.f10167a;
            this.f10168b = d + this.f10168b;
            this.f10169c = i + this.f10169c;
            this.f10170d += summary.getStepWalkDistance();
            this.f10171e += summary.getStepWalkDuration();
            this.f10172f += summary.getStepWalkCalories();
            this.f10173g += summary.getStepRunDistance();
            this.f10174h += summary.getStepRunDuration();
            this.f10175i += summary.getStepRunCalories();
        }

        protected abstract String m14822b(SportDay sportDay);

        protected void m14823b() {
            View view = (View) this.f10187u.ao.get(this.f10187u.f9386s);
            View findViewById = view.findViewById(R.id.info_weight);
            TextView textView = (TextView) view.findViewById(R.id.info_weight_body_type);
            TextView textView2 = (TextView) view.findViewById(R.id.info_weight_bmi);
            ChartData.m8735a(findViewById, "--", C3657a.f18328f);
            textView.setText("--");
            textView2.setText("--");
        }

        protected void m14824b(View view) {
            TextView textView = (TextView) view.findViewById(R.id.info_step);
            View findViewById = view.findViewById(R.id.info_step_distance);
            View findViewById2 = view.findViewById(R.id.info_step_calorie);
            TextView textView2 = (TextView) view.findViewById(R.id.info_step_average);
            View findViewById3 = view.findViewById(R.id.info_step_distance_average);
            View findViewById4 = view.findViewById(R.id.info_step_calorie_average);
            View findViewById5 = view.findViewById(R.id.info_step_walk_distance_average);
            View findViewById6 = view.findViewById(R.id.info_step_walk_duration_average);
            View findViewById7 = view.findViewById(R.id.info_step_walk_calories_average);
            View findViewById8 = view.findViewById(R.id.info_step_run_distance_average);
            View findViewById9 = view.findViewById(R.id.info_step_run_duration_average);
            View findViewById10 = view.findViewById(R.id.info_step_run_calories_average);
            textView.setText(ChartData.m8733a((long) this.f10167a));
            String[] a = ChartData.m8736a(this.f10187u.getActivity(), this.f10168b);
            ChartData.m8735a(findViewById, a[0], a[1]);
            ChartData.m8735a(findViewById2, ChartData.m8733a((long) this.f10169c), this.f10187u.getString(R.string.unit_calorie));
            if (this.f10184r == 0) {
                this.f10184r = 1;
            }
            textView2.setText(ChartData.m8733a((long) (this.f10167a / this.f10184r)));
            a = ChartData.m8736a(this.f10187u.getActivity(), this.f10168b / this.f10184r);
            ChartData.m8735a(findViewById3, a[0], a[1]);
            ChartData.m8735a(findViewById4, ChartData.m8733a((long) (this.f10169c / this.f10184r)), this.f10187u.getString(R.string.unit_calorie));
            if ((this.f10187u.aC & 2) > 0) {
                a = ChartData.m8736a(this.f10187u.getActivity(), this.f10170d / this.f10184r);
                ChartData.m8735a(findViewById5, a[0], a[1]);
                ChartData.m8734a(findViewById6, this.f10171e / this.f10184r, this.f10187u.getActivity());
                ChartData.m8735a(findViewById7, ChartData.m8733a((long) (this.f10172f / this.f10184r)), this.f10187u.getString(R.string.unit_calorie));
                a = ChartData.m8736a(this.f10187u.getActivity(), this.f10173g / this.f10184r);
                ChartData.m8735a(findViewById8, a[0], a[1]);
                ChartData.m8734a(findViewById9, this.f10174h / this.f10184r, this.f10187u.getActivity());
                ChartData.m8735a(findViewById10, ChartData.m8733a((long) (this.f10175i / this.f10184r)), this.f10187u.getString(R.string.unit_calorie));
            }
        }

        protected abstract boolean m14825b(int i);

        protected abstract void m14826c(int i);

        protected void m14827c(View view) {
            int age;
            float a;
            int i;
            CharSequence a2 = null;
            View findViewById = view.findViewById(R.id.info_weight);
            TextView textView = (TextView) view.findViewById(R.id.info_weight_body_type);
            TextView textView2 = (TextView) view.findViewById(R.id.info_weight_bmi);
            if (this.f10186t == 0) {
                this.f10186t = 1;
            }
            float f = this.f10182p / ((float) this.f10186t);
            if (this.f10187u.f9362E == -1) {
                PersonInfo readPersonInfoBase = Keeper.readPersonInfoBase();
                age = Birthday.fromStr(readPersonInfoBase.birthday).getAge();
                a = WeightUtil.m15693a(readPersonInfoBase.height, age, f);
                i = readPersonInfoBase.gender;
            } else {
                UserInfo a3 = this.f10187u.f9359B.getInfoByUid(this.f10187u.f9362E);
                age = Birthday.fromStr(a3.birthday).getAge();
                a = WeightUtil.m15693a(a3.height, age, f);
                i = a3.gender;
            }
            CharSequence b = WeightUtil.m15709b(a);
            String str = "--";
            if (f > 0.0f) {
                a2 = WeightUtil.m15697a(this.f10187u.getActivity(), a, age, i);
            } else {
                Object obj = str;
            }
            age = Keeper.readPersonInfo().miliConfig.weightUnit;
            ChartData.m8735a(findViewById, String.valueOf(WeightUtil.m15715c(WeightUtil.m15706b(f, age))), WeightUtil.m15698a(this.f10187u.getActivity(), age));
            textView.setText(a2);
            textView2.setText(b);
        }

        protected void m14828c(SportDay sportDay) {
            DaySportData.Summary summary = (DaySportData.Summary) this.f10187u.f9381X.get(sportDay.getKey());
            if (summary != null && !summary.isEmpty()) {
                if (summary.getSteps() > 0) {
                    m14821a(sportDay, summary, null);
                    this.f10184r++;
                }
                if (summary.getSleep() > 0) {
                    m14820a(summary);
                    this.f10185s++;
                }
                if (this.f10187u.az == null) {
                    this.f10187u.az = sportDay;
                    this.f10187u.aA = summary.getSteps();
                } else if (this.f10187u.aA < summary.getSteps()) {
                    this.f10187u.aA = summary.getSteps();
                    this.f10187u.az = sportDay;
                    GuliLog.tracePrintInfo("Statistic.Main", "find a bigger steps: " + this.f10187u.aA);
                }
            }
        }
    }

    class fb extends fa {
        private String f10188A;
        private String f10189B;
        final /* synthetic */ StatisticFragment f10190v;
        private String[] f10191w;
        private String f10192x;
        private String f10193y;
        private String f10194z;

        public fb(StatisticFragment statisticFragment) {
            super(statisticFragment);
            this.f10190v = statisticFragment;

            this.f10191w = statisticFragment.getResources().getStringArray(R.array.weeks);
            this.f10192x = statisticFragment.getString(R.string.date_today);
            this.f10193y = statisticFragment.getString(R.string.date_yesterday);
            this.f10194z = statisticFragment.getString(R.string.date_month_day);
            this.f10188A = statisticFragment.getString(R.string.date_year_month_day);
            this.f10189B = statisticFragment.getString(R.string.date_month_day_short);
        }

        protected C0738L m14812a (int i) { // m14829a
            int i2 = 0;
            C0738L c0738l = new C0738L();
            if (this.f10190v.f9385r == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                WeightInfo weightInfo = (WeightInfo) this.f10190v.f9382Y.get(-i);
                if (weightInfo == null) {
                    weightInfo = this.f10190v.f9358A.m15743a(this.f10190v.f9362E, -i);
                    this.f10190v.f9382Y.put(-i, weightInfo);
                }
                if (weightInfo != null) {
                    GuliLog.tracePrintInfo("Statistic.Main", "Load WeightInfo : " + weightInfo);
                    c0738l.f3902e = weightInfo.weight;
                    c0738l.f3903f = StatisticFragment.m14139a(weightInfo.timestamp);
                }
            } else {
                DaySportData.Summary summary;
                SportDay addDay = this.f10190v.f9389v.addDay(i);
                GuliLog.tracePrintInfo("Statistic.Main", "Load Day : " + addDay);
                String key = addDay.getKey();
                if (this.f10190v.f9381X.containsKey(key)) {
                    summary = (Summary) this.f10190v.f9381X.get(key);
                } else {
                    Summary a = this.f10190v.f9387t.m12199a(this.f10190v.aF, addDay);
                    this.f10190v.f9381X.put(key, a);
                    summary = a;
                }
                if (summary != null) {
                    int steps = summary.getSteps();
                    int sleep = summary.getSleep();
                    int sleepDeepTime = summary.getSleepDeepTime();
                    if (steps < 0) {
                        steps = 0;
                    }
                    c0738l.f3898a = steps;
                    c0738l.f3900c = sleep < 0 ? 0 : sleep;
                    if (sleepDeepTime >= 0) {
                        i2 = sleepDeepTime;
                    }
                    c0738l.f3901d = i2;
                }
                c0738l.f3903f = m14822b(addDay);
            }
            return c0738l;
        }

        protected ShareData m14814a(SportDay sportDay, int i) { // m14830a
            ShareData shareData = new ShareData();
            if (i == 16) {
                m14817a(this.f10190v.f9386s, shareData, sportDay);
                if (sportDay.equals(this.f10190v.f9388u)) {
                    shareData.title = this.f10190v.getString(R.string.share_sleep_title);
                } else {
                    shareData.title = this.f10190v.getString(R.string.share_sleep_title_daily);
                }
            } else if (i == 1) {
                Utils.m7972a(this.f10190v.getActivity(), this.f10167a, this.f10168b, this.f10173g, this.f10169c, this.f10190v.f9390w, shareData);
                shareData.time = Utils.m8058d(this.f10190v.f9390w);
                if (shareData.mExtraData == null) {
                    Bundle bundle = new Bundle();
                    bundle.putInt(ClientDataConstants.ax, ShareData.TimeType.DAY.ordinal());
                    bundle.putInt("data_type", C3843c.MILI.m25103b());
                    bundle.putInt(ClientDataConstants.aw, this.f10167a);
                    bundle.putString("date", sportDay.toString());
                    shareData.mExtraData = bundle;
                }
                shareData.ranking = C3657a.f18328f;
            }
            return shareData;
        }

        protected String m14815a (SportDay sportDay) { // m14831a
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
            if (sportDay.equals(this.f10190v.f9388u)) {
                return this.f10192x;
            }
            if (sportDay.offsetDay(this.f10190v.f9388u) == -1 && !this.f10190v.aB) {
                return this.f10193y;
            }
            if (sportDay.mon + 1 == 1 && sportDay.day == 1) {
                simpleDateFormat.applyPattern(this.f10188A);
            } else {
                simpleDateFormat.applyPattern(this.f10194z);
            }
            return simpleDateFormat.format(new Date(sportDay.getCalendar().getTimeInMillis()));
        }

        protected String m14822b (SportDay sportDay) { // m14832b
            boolean equals = sportDay.equals(this.f10190v.f9388u);
            int i = sportDay.offsetDay(this.f10190v.f9388u) == -1 ? 1 : 0;
            int i2 = this.f10190v.aB ? 6 : 0;
            int i3 = sportDay.getWeek() == i2 ? 1 : 0;
            int i4 = (sportDay.mon + 1 == 1 && sportDay.day == 1) ? 1 : 0;
            if (equals) {
                return this.f10192x;
            }
            if (i3 != 0 && i4 == 0) {
                return this.f10191w[i2];
            }
            if (i != 0 && !this.f10190v.aB && i4 == 0) {
                return this.f10193y;
            }
            String format = String.format(this.f10189B, new Object[]{Integer.valueOf(sportDay.mon + 1), Integer.valueOf(sportDay.day)});
            return i4 != 0 ? sportDay.year + "/" + format : format;
        }

        protected void m14833b(View view) {
            TextView textView = (TextView) view.findViewById(R.id.info_step);
            View findViewById = view.findViewById(R.id.info_step_distance);
            View findViewById2 = view.findViewById(R.id.info_step_calorie);
            View findViewById3 = view.findViewById(R.id.info_step_walk_distance);
            View findViewById4 = view.findViewById(R.id.info_step_walk_duration);
            View findViewById5 = view.findViewById(R.id.info_step_walk_calorie);
            View findViewById6 = view.findViewById(R.id.info_step_run_distance);
            View findViewById7 = view.findViewById(R.id.info_step_run_duration);
            View findViewById8 = view.findViewById(R.id.info_step_run_calorie);
            textView.setText(ChartData.m8733a((long) this.f10167a));
            String[] a = ChartData.m8736a(this.f10190v.getActivity(), this.f10168b);
            ChartData.m8735a(findViewById, a[0], a[1]);
            ChartData.m8735a(findViewById2, ChartData.m8733a((long) this.f10169c), this.f10190v.getString(R.string.unit_calorie));
            if ((this.f10190v.aC & 2) > 0) {
                a = ChartData.m8736a(this.f10190v.getActivity(), this.f10170d);
                ChartData.m8735a(findViewById3, a[0], a[1]);
                ChartData.m8734a(findViewById4, this.f10171e, this.f10190v.getActivity());
                ChartData.m8735a(findViewById5, ChartData.m8733a((long) this.f10172f), this.f10190v.getString(R.string.unit_calorie));
                a = ChartData.m8736a(this.f10190v.getActivity(), this.f10173g);
                ChartData.m8735a(findViewById6, a[0], a[1]);
                ChartData.m8734a(findViewById7, this.f10174h, this.f10190v.getActivity());
                ChartData.m8735a(findViewById8, ChartData.m8733a((long) this.f10175i), this.f10190v.getString(R.string.unit_calorie));
            }
        }

        protected boolean m14825b (int i) { // m14834b
            if (this.f10190v.f9385r == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                if (i <= 0 && i > (-this.f10190v.f9360C)) {
                    return true;
                }
                GuliLog.tracePrintWarn("Statistic.Main", "Has data False : " + i);
                return false;
            } else if (i <= 0 && i >= f10190v.f9391x.offsetDay(this.f10190v.f9389v)) {
                return true;
            } else {
                GuliLog.tracePrintWarn("Statistic.Main", "Has data False : " + i);
                return false;
            }
        }

        protected void m14826c (int i) { // m14835c
            m14816a();
            if (this.f10190v.f9385r == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                this.f10190v.f9368K = i;
//                this.f10190v.f9363F;
                this.f10190v.f9363F = (WeightInfo) this.f10190v.f9382Y.get(-i);
                if (this.f10190v.f9363F != null) {
                    m14819a(this.f10190v.f9363F);
                    m14827c((View) this.f10190v.ao.get(1));
                    return;
                }
                return;
            }
            SportDay addDay = this.f10190v.f9389v.addDay(i);
            GuliLog.tracePrintInfo("Statistic.Main", "To Day : " + addDay);
            this.f10190v.f9390w = addDay;
            this.f10190v.m14155a(addDay);
            m14828c(addDay);
            m14818a((View) this.f10190v.am.get(1));
            m14833b((View) this.f10190v.an.get(1));
            if (this.f10190v.aH) {
                C0668a.m8126a(this.f10190v.getActivity(), C0708b.by);
            }
        }
    }

    class fc extends fa {
        private String f10195A;
        private String f10196B;
        final /* synthetic */ StatisticFragment f10197v;
        private final String f10198w;
        private final String f10199x;
        private String f10200y;
        private String f10201z;

        public fc(StatisticFragment statisticFragment) {
            super(statisticFragment);
            this.f10197v = statisticFragment;

            this.f10200y = statisticFragment.getString(R.string.date_this_month);
            this.f10201z = statisticFragment.getString(R.string.date_last_month);
            this.f10195A = statisticFragment.getString(R.string.date_month);
            this.f10196B = statisticFragment.getString(R.string.date_year_month);
            this.f10198w = statisticFragment.getString(R.string.date_month_day_short);
            this.f10199x = statisticFragment.getString(R.string.date_from_to_short);
        }

        protected C0738L m14812a (int i) { // m14836a
            SportDay addMonth = this.f10197v.f9389v.addMonth(i);
            GuliLog.tracePrintInfo("Statistic.Main", "Load Month : " + m14815a(addMonth));
            SportDay monthStartDay = addMonth.getMonthStartDay();
            SportDay monthEndDay = addMonth.getMonthEndDay();
            GuliLog.tracePrintInfo("Statistic.Main", monthStartDay + "~" + monthEndDay);
            int i2 = 0;
            int i3 = 0;
            int i4 = 0;
            float f = 0.0f;
            int i5 = 0;
            int i6 = 0;
            int i7 = 0;
            for (int i8 = 0; i8 < monthEndDay.day; i8++) {
                Summary summary;
                SportDay addDay = monthStartDay.addDay(i8);
                GuliLog.tracePrintInfo("Statistic.Main", "Load Day : " + addDay);
                String key = addDay.getKey();
                if (this.f10197v.f9381X.containsKey(key)) {
                    summary = (Summary) this.f10197v.f9381X.get(key);
                } else {
                    summary = this.f10197v.f9387t.m12199a(this.f10197v.aF, addDay);
                    this.f10197v.f9381X.put(key, summary);
                }
                if (summary != null) {
                    if (summary.getSteps() > 0) {
                        i2 += summary.getSteps();
                        i5++;
                    }
                    if (summary.getSleep() > 0) {
                        i3 += summary.getSleep();
                        i4 += summary.getSleepDeepTime();
                        i6++;
                    }
                }
                if (this.f10197v.f9385r == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                    WeightInfo b = this.f10197v.f9358A.m15759b(this.f10197v.f9362E, addDay.getCalendar());
                    if (b != null) {
                        f += b.weight;
                        i7++;
                    }
                }
            }
            C0738L a = m14813a(i2, 0, i3, i4, f, i5, i6, i7);
            a.f3903f = m14822b(addMonth);
            return a;
        }

        protected ShareData m14814a(SportDay sportDay, int i) { // m14837a
            String str;
            String a;
            ShareData shareData = new ShareData();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
            if (sportDay.offsetMonth(this.f10197v.f9388u) == 0) {
                str = this.f10200y;
            } else {
                simpleDateFormat.applyPattern(this.f10195A);
                str = this.f10197v.getString(R.string.in) + simpleDateFormat.format(new Date(sportDay.getCalendar().getTimeInMillis()));
            }
            if (i == 16) {
                m14817a(this.f10197v.f9386s, shareData, sportDay);
                shareData.title = str + ", " + this.f10197v.getString(R.string.share_sleep_title_average);
            } else if (i == 1) {
                shareData.setType(6);
                a = Utils.m7978a(this.f10197v.getActivity(), this.f10167a, this.f10168b, this.f10169c, Utils.m8058d(this.f10197v.az), this.f10197v.aA, this.f10173g);
                shareData.title = str + this.f10197v.getString(R.string.share_step_walk);
                shareData.content = C3657a.f18328f + this.f10167a;
                shareData.description = a;
                shareData.contentUnit = this.f10197v.getString(R.string.unit_step);
                Bundle bundle = new Bundle();
                bundle.putInt(ClientDataConstants.ax, ShareData.TimeType.MONTH.ordinal());
                bundle.putInt("data_type", C3843c.MILI.m25103b());
                bundle.putInt(ClientDataConstants.aw, this.f10167a);
                shareData.mExtraData = bundle;
//                shareData.ranking = new C0900e().m9102a(this.f10197v.getActivity(), this.a);
            }
            SportDay monthStartDay = sportDay.getMonthStartDay();
            SportDay addDay = monthStartDay.addMonth(1).addDay(-1);
            if (sportDay.offsetMonth(this.f10197v.f9388u) == 0) {
                addDay = this.f10197v.f9388u;
            }
            if (monthStartDay.before(this.f10197v.f9391x)) {
                monthStartDay = this.f10197v.f9391x;
            } else if (addDay.after(this.f10197v.f9392y)) {
                addDay = this.f10197v.f9392y;
            }
            String format = String.format(this.f10198w, new Object[]{Integer.valueOf(monthStartDay.mon + 1), Integer.valueOf(monthStartDay.day)});
            a = String.format(this.f10198w, new Object[]{Integer.valueOf(addDay.mon + 1), Integer.valueOf(addDay.day)});
            shareData.time = String.format(this.f10199x, new Object[]{format, a});
            return shareData;
        }

        protected String m14815a (SportDay sportDay) { // m14838a
            if (sportDay.offsetMonth(this.f10197v.f9388u) == 0) {
                return this.f10200y;
            }
            if (sportDay.offsetMonth(this.f10197v.f9388u) == -1) {
                return this.f10201z;
            }
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
            if (sportDay.mon + 1 == 1) {
                simpleDateFormat.applyPattern(this.f10196B);
                return simpleDateFormat.format(new Date(sportDay.getCalendar().getTimeInMillis()));
            }
            simpleDateFormat.applyPattern(this.f10195A);
            return simpleDateFormat.format(new Date(sportDay.getCalendar().getTimeInMillis()));
        }

        protected String m14822b (SportDay sportDay) { // m14839b
            return m14815a(sportDay);
        }

        protected boolean m14825b (int i) { // m14840b
            if (i <= 0 && i >= this.f10197v.f9391x.offsetMonth(this.f10197v.f9389v)) {
                return true;
            }
            GuliLog.tracePrintWarn("Statistic.Main", "Has data False : " + i);
            return false;
        }

        protected void m14826c (int i) { // m14841c
            SportDay addMonth = this.f10197v.f9389v.addMonth(i);
            SportDay monthStartDay = addMonth.getMonthStartDay();
            SportDay monthEndDay = addMonth.getMonthEndDay();
            GuliLog.tracePrintInfo("Statistic.Main", monthStartDay + "~" + monthEndDay);
            GuliLog.tracePrintInfo("Statistic.Main", "To Month : " + m14815a(addMonth));
            this.f10197v.f9366I = i;
            if (this.f10197v.f9367J == Integer.MAX_VALUE) {
                this.f10197v.f9367J = i;
            }
            if (this.f10197v.f9367J == i) {
                this.f10197v.f9390w = this.f10197v.f9393z;
            } else {
                this.f10197v.f9390w = monthStartDay;
                if (this.f10197v.f9390w.before(this.f10197v.f9391x)) {
                    this.f10197v.f9390w = this.f10197v.f9391x;
                }
            }
            this.f10197v.m14155a(addMonth);
            m14816a();
            for (int i2 = 0; i2 < monthEndDay.day; i2++) {
                SportDay addDay = monthStartDay.addDay(i2);
                GuliLog.tracePrintInfo("Statistic.Main", "Load Day : " + addDay);
                m14828c(addDay);
            }
            m14818a((View) this.f10197v.am.get(PersonInfo.INCOMING_CALL_DISABLE_BIT));
            m14824b((View) this.f10197v.an.get(PersonInfo.INCOMING_CALL_DISABLE_BIT));
        }
    }

    class fd extends fa {
        private String f10202A;
        private String f10203B;
        private String f10204C;
        final /* synthetic */ StatisticFragment f10205v;
        private String f10206w;
        private String f10207x;
        private String f10208y;
        private String f10209z;

        public fd(StatisticFragment statisticFragment) {
            super(statisticFragment);
            this.f10205v = statisticFragment;
            this.f10206w = statisticFragment.getString(R.string.date_this_week);
            this.f10207x = statisticFragment.getString(R.string.date_last_week);
            this.f10208y = statisticFragment.getString(R.string.date_from_to);
            this.f10209z = statisticFragment.getString(R.string.date_from_to_short);
            this.f10202A = statisticFragment.getString(R.string.date_month_day);
            this.f10203B = statisticFragment.getString(R.string.date_year_month_day);
            this.f10204C = statisticFragment.getString(R.string.date_month_day_short);
        }

        protected C0738L m14812a (int i) { // m14842a
            SportDay addWeek = this.f10205v.f9389v.addWeek(i);
            GuliLog.tracePrintInfo("Statistic.Main", "Load Week : " + m14815a(addWeek));
            SportDay weekStartDay = addWeek.getWeekStartDay();
            int i2 = 0;
            int i3 = 0;
            int i4 = 0;
            int i5 = 0;
            int i6 = 0;
            int i7 = 0;
            int i8 = 0;
            int i9 = 0;
            while (i9 < 7) {
                Summary summary;
                int i10;
                SportDay addDay = weekStartDay.addDay(i9);
                GuliLog.tracePrintInfo("Statistic.Main", "Load Day : " + addDay);
                String key = addDay.getKey();
                if (this.f10205v.f9381X.containsKey(key)) {
                    summary = (Summary) this.f10205v.f9381X.get(key);
                } else {
                    summary = this.f10205v.f9387t.m12199a(this.f10205v.aF, addDay);
                    f10205v.f9381X.put(key, summary);
                }
                if (summary != null) {
                    if (summary.getSteps() > 0) {
                        i2 += summary.getSteps();
                        i6++;
                    }
                    if (summary.getSleep() > 0) {
                        i3 += summary.getSleep();
                        i4 += summary.getSleepDeepTime();
                        i7++;
                    }
                }
                if (this.f10205v.f9385r == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
                    WeightInfo b = this.f10205v.f9358A.m15759b(this.f10205v.f9362E, addDay.getCalendar());
                    if (b != null) {
                        i10 = (int) (b.weight + ((float) i5));
                        i8++;
                        i9++;
                        i5 = i10;
                    }
                }
                i10 = i5;
                i9++;
                i5 = i10;
            }
            C0738L a = m14813a(i2, 0, i3, i4, (float) i5, i6, i7, i8);
            a.f3903f = m14822b(addWeek);
            return a;
        }

        protected ShareData m14814a (SportDay sportDay, int i) { // m14843a
            String string;
            ShareData shareData = new ShareData();
            if (i == 16) {
                m14817a(this.f10205v.f9386s, shareData, sportDay);
                string = this.f10205v.getString(R.string.week);
                if (sportDay.offsetWeek(this.f10205v.f9388u) == 0) {
                    string = this.f10206w;
                }
                shareData.title = string + this.f10205v.getString(R.string.share_sleep_title_average);
            } else if (i == 1) {
                shareData.setType(7);
                string = this.f10205v.getString(R.string.one_week);
                if (sportDay.offsetWeek(this.f10205v.f9388u) == 0) {
                    string = this.f10206w;
                }
                shareData.title = string + this.f10205v.getString(R.string.share_step_walk);
                shareData.content = C3657a.f18328f + this.f10167a;
                shareData.description = Utils.m7979a(this.f10205v.getActivity(), this.f10168b, this.f10169c, this.f10205v.getResources().getStringArray(R.array.weeks)[this.f10205v.az.getWeek()], this.f10205v.aA, this.f10173g);
                shareData.contentUnit = this.f10205v.getString(R.string.unit_step);
                Bundle bundle = new Bundle();
                bundle.putInt(ClientDataConstants.ax, ShareData.TimeType.WEEK.ordinal());
                bundle.putInt("data_type", C3843c.MILI.m25103b());
                bundle.putInt(ClientDataConstants.aw, this.f10167a);
                shareData.mExtraData = bundle;
//                shareData.ranking = new C0903h().m9102a(this.f10205v.getActivity(), this.a);
            }
            SportDay weekStartDay = sportDay.getWeekStartDay();
            SportDay addDay = weekStartDay.addDay(6);
            if (sportDay.offsetWeek(f10205v.f9388u) == 0) {
                addDay = this.f10205v.f9388u;
            }
            if (weekStartDay.before(this.f10205v.f9391x)) {
                weekStartDay = this.f10205v.f9391x;
            } else if (addDay.after(this.f10205v.f9392y)) {
                addDay = this.f10205v.f9392y;
            }
            String format = String.format(this.f10204C, new Object[]{Integer.valueOf(weekStartDay.mon + 1), Integer.valueOf(weekStartDay.day)});
            string = String.format(this.f10204C, new Object[]{Integer.valueOf(addDay.mon + 1), Integer.valueOf(addDay.day)});
            shareData.time = String.format(this.f10209z, new Object[]{format, string});
            return shareData;
        }

        protected String m14815a (SportDay sportDay) { // m14844a
            if (sportDay.offsetWeek(this.f10205v.f9388u) == 0) {
                return this.f10206w;
            }
            if (sportDay.offsetWeek(this.f10205v.f9388u) == -1) {
                return this.f10207x;
            }
            SportDay weekStartDay = sportDay.getWeekStartDay();
            SportDay addDay = weekStartDay.addDay(6);
            if (weekStartDay.before(this.f10205v.f9391x)) {
                weekStartDay = this.f10205v.f9391x;
            } else if (addDay.after(this.f10205v.f9392y)) {
                addDay = this.f10205v.f9392y;
            }
            Date date = new Date();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(this.f10202A);
            SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(this.f10203B);
            date.setTime(weekStartDay.getCalendar().getTimeInMillis());
            String format = (weekStartDay.mon + 1 == 1 && weekStartDay.calendar.get(Calendar.WEEK_OF_YEAR) == 1) ? simpleDateFormat2.format(date) : simpleDateFormat.format(date);
            date.setTime(addDay.getCalendar().getTimeInMillis());
            String format2 = (addDay.mon + 1 == 1 && addDay.calendar.get(Calendar.WEEK_OF_YEAR) == 1) ? simpleDateFormat2.format(date) : simpleDateFormat.format(date);
            return String.format(this.f10208y, new Object[]{format, format2});
        }

        protected String m14822b (SportDay sportDay) { // m14845b
            if (sportDay.offsetWeek(this.f10205v.f9388u) == 0) {
                return this.f10206w;
            }
            if (sportDay.offsetWeek(this.f10205v.f9388u) == -1) {
                return this.f10207x;
            }
            SportDay weekStartDay = sportDay.getWeekStartDay();
            SportDay addDay = weekStartDay.addDay(6);
            if (weekStartDay.before(this.f10205v.f9391x)) {
                weekStartDay = this.f10205v.f9391x;
            } else if (addDay.after(this.f10205v.f9392y)) {
                addDay = this.f10205v.f9392y;
            }
            String format = String.format(this.f10204C, new Object[]{Integer.valueOf(weekStartDay.mon + 1), Integer.valueOf(weekStartDay.day)});
            String format2 = String.format(this.f10204C, new Object[]{Integer.valueOf(addDay.mon + 1), Integer.valueOf(addDay.day)});
            return String.format(this.f10209z, new Object[]{format, format2});
        }

        protected boolean m14825b (int i) { // m14846b
            if (i <= 0 && i >= this.f10205v.f9391x.offsetWeek(this.f10205v.f9389v)) {
                return true;
            }
            GuliLog.tracePrintWarn("Statistic.Main", "Has data False : " + i);
            return false;
        }

        protected void m14826c  (int i) { // m14841c
            SportDay addWeek = this.f10205v.f9389v.addWeek(i);
            SportDay weekStartDay = addWeek.getWeekStartDay();
            GuliLog.tracePrintInfo("Statistic.Main", "To Week : " + m14815a(addWeek));
            this.f10205v.f9366I = i;
            if (this.f10205v.f9367J == Integer.MAX_VALUE) {
                this.f10205v.f9367J = i;
            }
            if (this.f10205v.f9367J == i) {
                this.f10205v.f9390w = this.f10205v.f9393z;
            } else {
                this.f10205v.f9390w = weekStartDay;
                if (this.f10205v.f9390w.before(this.f10205v.f9391x)) {
                    this.f10205v.f9390w = this.f10205v.f9391x;
                }
            }
            this.f10205v.m14155a(addWeek);
            m14816a();
            for (int i2 = 0; i2 < 7; i2++) {
                SportDay addDay = weekStartDay.addDay(i2);
                GuliLog.tracePrintInfo("Statistic.Main", "Load Day : " + addDay);
                m14828c(addDay);
            }
            m14818a((View) this.f10205v.am.get(16));
            m14824b((View) this.f10205v.an.get(16));
        }
    }



    private void m14187f() {
        this.f9374Q = m14190g();
        this.f9375R = new SparseArray(f9355o);
        m14142a((int) f9356p, this.f9374Q, this.f9375R);
        m14142a((int) f9357q, this.f9374Q, this.f9375R);
        m14142a((int) f9346f, this.f9374Q, this.f9375R);
        int daySportGoalSteps = Keeper.readPersonInfo().getDaySportGoalSteps();
        this.ae.m8399d(true);
        this.ae.m8557e(daySportGoalSteps);
        this.ae.attach();
        if (this.af != null) {
            this.af.m8399d(true);
            this.af.m8557e(daySportGoalSteps);
            this.af.attach();
            this.af.setVisibility(View.INVISIBLE);
        }
        this.f9384b = this.ae;
        this.f9373P = new SparseArray(f9355o);
        this.f9373P.put(f9356p, new fb(this));
        this.f9373P.put(f9357q, new fd(this));
        this.f9373P.put(f9346f, new fc(this));
    }

    class eS implements ChartDataLoader.LoadCallback {
        final /* synthetic */ StatisticFragment f10061a;

        eS(StatisticFragment statisticFragment) {
            this.f10061a = statisticFragment;
        }

        public void onDataLoaded(ItemData c0737e) {
            if (this.f10061a.f9384b == null || !this.f10061a.f9384b.isAttached()) {
                GuliLog.tracePrintWarn("Statistic.Main", "Chart Already Detached From UI : onDataLoaded , " + this.f10061a.f9384b);
            } else if (this.f10061a.ax) {
                AnimUtil.m8755a((ViewGroup) this.f10061a.aq, (ViewGroup) this.f10061a.ap);
                if ((this.f10061a.aC & 2) == 0) {
                    this.f10061a.m14193h();
                }
                if (this.f10061a.ay) {
                    this.f10061a.av = this.f10061a.m14134a(this.f10061a.f9384b, this.f10061a.ag, (int) this.f10061a.ag.m8554d(), this.f10061a.ag.getWidth(), this.f10061a.f9369L, this.f10061a.f9370M, 450);
                } else {
                    this.f10061a.f9371N = this.f10061a.f9384b.m8543a(this.f10061a.f9385r, this.f10061a.f9368K);
                    if (this.f10061a.f9371N != null) {
                        this.f10061a.f9369L = (int) this.f10061a.f9371N.getRect().height();
                        int i = this.f10061a.f9371N.f3883b;
                        this.f10061a.f9370M = (int) ((((float) ((StatisticChart.StatisticBarItem) (this.f10061a.f9371N)).f3887a) / ((float) i)) * ((float) this.f10061a.f9369L));
                    } else {
                        this.f10061a.f9369L = 0;
                        this.f10061a.f9370M = 0;
                    }
                    GuliLog.tracePrintInfo("Statistic.Main", "BarItem Height : " + this.f10061a.f9369L);
                    this.f10061a.av = this.f10061a.m14160b(this.f10061a.f9384b, this.f10061a.ag, this.f10061a.f9384b.getWidth(), (int) this.f10061a.f9384b.m8554d(), this.f10061a.f9369L, this.f10061a.f9370M, 450);
                }
                this.f10061a.av.start();
            } else if (this.f10061a.f9376S) {
                this.f10061a.f9376S = false;
                if ((this.f10061a.aC & 2) == 0) {
                    this.f10061a.m14193h();
                }
                if (this.f10061a.aw == null) {
                    this.f10061a.aw = this.f10061a.f9384b.m8540a();
                }
                if (!this.f10061a.aw.isStarted()) {
                    this.f10061a.f9384b.m8548b();
                    this.f10061a.aw.addListener(new eT(this));
                    this.f10061a.aw.setDuration(300);
                    if (this.f10061a.f9377T) {
                        this.f10061a.aw.setStartDelay(150);
                        this.f10061a.f9377T = false;
                    }
                    if (this.f10061a.f9365H) {
                        this.f10061a.aw.setInterpolator(new DecelerateInterpolator());
                    }
                    this.f10061a.aw.start();
                }
            }
        }

        public boolean hasData(int i) {
            return this.f10061a.f9372O.m14825b(i);
        }

        public ItemData loadData(int i) {
            return this.f10061a.f9372O.m14812a(i);
        }

        public void onToItem(int i) {
            if (this.f10061a.f9384b == null || !this.f10061a.f9384b.isAttached()) {
                GuliLog.tracePrintWarn("Statistic.Main", "Chart Already Detached From UI : onToItem , " + this.f10061a.f9384b);
            } else {
                this.f10061a.f9372O.m14826c(i);
            }
        }
    }

    private ChartDataLoader.LoadCallback m14190g() {
        return new eS(this);
    }

    private void m14193h() {
        int i;
        ViewGroup viewGroup = (ViewGroup) this.ap;
        for (i = f9355o; i <= f9349i; i += f9356p) {
            if (this.f9386s == f9356p) {
                viewGroup.getChildAt(i).setVisibility(View.INVISIBLE);
            } else {
                viewGroup.getChildAt(i).setVisibility(View.GONE);
            }
        }
        for (i = 6; i <= 8; i += f9356p) {
            viewGroup.getChildAt(i).setVisibility(View.GONE);
        }
    }

    private void m14195i() {
//        if (this.aD == null) {
//            this.aD = new C1693p(getActivity());
//        }
//        this.aD.m13260h();
//        C0668a.m8126a(getActivity(), C0708b.bz);
    }

     static public class eZ extends DimPanelFragment {
        static  /* synthetic */ StatisticFragment f10070a;

        private eZ(StatisticFragment statisticFragment) {
            this.f10070a = statisticFragment;
        }

        protected int inflateLayout() {
            return R.layout.dialog_weight_info_modify_delete_confirm;
        }

        public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
            View onCreateView = super.onCreateView(layoutInflater, viewGroup, bundle);
            Bundle arguments = getArguments();
            if (!(arguments == null || arguments.getString("Msg") == null)) {
                ((TextView) onCreateView.findViewById(R.id.msg)).setText(arguments.getString("Msg"));
            }
            return onCreateView;
        }
    }

    static class eU implements C1154e {
        static  /* synthetic */ DimPanelFragment f10063a;
        static  /* synthetic */ StatisticFragment f10064b;

        eU(StatisticFragment statisticFragment, DimPanelFragment c1185c) {
            this.f10064b = statisticFragment;
            this.f10063a = c1185c;
        }

        public void m10600a(DialogFragment dialogFragment) {
        }

        public void m10601b(DialogFragment dialogFragment) {
            this.f10063a.dismiss();
        }

        public void m10602c(DialogFragment dialogFragment) {
            this.f10063a.dismiss();
            this.f10064b.m14152a(this.f10064b.f9363F);
        }
    }

    private void m14198j() {
        eZ eZVar = new eZ(this);
        eZVar.setOpClickListener(new eU(this, eZVar));
        Bundle bundle = new Bundle();
        Object[] objArr = new Object[f9356p];
        objArr[0] = DateFormat.format(C0893f.m9087a(Boolean.valueOf(true), this.f9363F.timestamp), this.f9363F.timestamp);
        bundle.putString("Msg", getString(R.string.weight_delete_confirm_msg, objArr));
        DimPanelFragment.showPanel(getActivity(), eZVar, bundle);
    }

    private void m14201k() {
    }

//    private void m14203l() {
//        Parcelable m = m14205m();
//        Intent intent = new Intent();
//        intent.setClass(getActivity(), ShareActivity.class);
//        intent.putExtra("share_data", m);
//        getActivity().startActivity(intent);
//        C0668a.m8128a(getActivity(), C0668a.aZ, C0668a.cw);
//    }

//    private ShareData m14205m() {
//        return this.f9372O.m14814a(this.f9390w, this.f9385r);
//    }

    private void m14207n() {
        if (this.au != null && this.au.isStarted()) {
            return;
        }
        if (this.av == null || !this.av.isStarted()) {
            this.ae.m8399d(false);
            this.af.m8399d(false);
            String str = C3657a.f18328f;
            int i = this.f9385r;
            if (i == f9357q) {
                this.f9385r = f9356p;
                str = C0668a.cO;
            } else if (i == f9356p) {
                this.f9385r = f9357q;
                str = C0668a.cP;
            }
            C0668a.m8144c(str);
            m14143a(this.f9385r, false);
            m14140a(i, this.f9385r, this.f9386s, this.f9386s, false);
            AnimUtil.m8761b((ViewGroup) this.aq, (ViewGroup) this.ap);
        }
    }

    class eV implements Runnable {
        final /* synthetic */ StatisticFragment f10065a;

        eV(StatisticFragment statisticFragment) {
            this.f10065a = statisticFragment;
        }

        public void run() {
            this.f10065a.m14172c(this.f10065a.f9368K);
        }
    }

    private void m14209o() {
        if (this.aH) {
            C0668a.m8126a(getActivity(), C0708b.bA);
        }
        if (this.av != null && this.av.isStarted()) {
            return;
        }
        if (this.au != null && this.au.isStarted()) {
            return;
        }
        if (this.aw != null && this.aw.isStarted()) {
            return;
        }
        if (this.f9385r != f9346f) {
            this.f9371N = this.f9384b.m8543a(this.f9385r, this.f9366I);
            if (this.f9371N != null) {
                this.f9369L = (int) this.f9371N.getRect().height();
                int i = this.f9371N.f3883b;
                this.f9370M = (int) ((((float) ((StatisticChart.StatisticBarItem) this.f9371N).f3887a) / ((float) i)) * ((float) this.f9369L));
            } else {
                this.f9369L = 0;
                this.f9370M = 0;
            }
            GuliLog.tracePrintInfo(f9343c, "BarItem Height : " + this.f9369L);
            int i2 = this.f9386s;
            if (this.f9386s == f9346f) {
                this.f9386s = f9357q;
                this.f9368K = this.f9390w.offsetWeek(this.f9389v);
                GuliLog.tracePrintInfo(f9343c, "Offset Week From Month : " + this.f9368K);
                this.f9384b = this.af;
                this.ag = this.ae;
            } else if (this.f9386s == f9357q) {
                this.f9386s = f9356p;
                this.f9368K = this.f9390w.offsetDay(this.f9389v);
                GuliLog.tracePrintInfo(f9343c, "Offset Day : " + this.f9368K);
                this.f9384b = this.ae;
                this.ag = this.af;
            }
            if (this.f9366I != this.f9367J) {
                this.f9393z = this.f9390w;
            }
            this.f9367J = Integer.MAX_VALUE;
            m14141a(i2, this.f9386s, false);
            this.ae.m8399d(false);
            this.af.m8399d(false);
            this.f9384b.m8556e();
            this.f9384b.m8555d(this.f9368K);
            this.f9384b.m8559f(this.f9368K);
            this.ax = true;
            this.ay = true;
        } else if (!this.f9365H && this.f9360C != 0) {
            this.f9365H = true;
            if (this.f9364G == f9352l) {
                this.f9364G = f9351k;
                this.al.setEnabled(true);
            } else if (this.f9364G == f9351k) {
                this.f9364G = f9350j;
                this.ak.setEnabled(false);
            }
            m14147a(this.f9384b, this.f9386s);
            Animator b = this.f9384b.m8547b(220, C0804t.m8825a(getActivity(), 185.0f), -1);
            b.setInterpolator(new AccelerateInterpolator());
            b.start();
            this.f9384b.postDelayed(new eV(this), b.getDuration() + 50);
        }
    }

    private void m14211p() {
        if (this.aH) {
            C0668a.m8126a(getActivity(), C0708b.bA);
        }
    }

    class eW implements Runnable {
        final /* synthetic */ StatisticFragment f10066a;

        eW(StatisticFragment statisticFragment) {
            this.f10066a = statisticFragment;
        }

        public void run() {
            this.f10066a.m14172c(this.f10066a.f9368K);
        }
    }

    private void m14213q() {
        if (this.aH) {
            C0668a.m8126a(getActivity(), C0708b.bA);
        }
        if (this.av != null && this.av.isStarted()) {
            return;
        }
        if (this.au != null && this.au.isStarted()) {
            return;
        }
        if (this.aw != null && this.aw.isStarted()) {
            return;
        }
        if (this.f9385r != f9346f) {
            int i = this.f9386s;
            if (this.f9386s == f9356p) {
                this.f9386s = f9357q;
                this.f9368K = this.f9390w.offsetWeek(this.f9389v);
                GuliLog.tracePrintInfo(f9343c, "Offset Week From Day : " + this.f9368K);
                this.f9384b = this.af;
                this.ag = this.ae;
            } else if (this.f9386s == f9357q) {
                this.f9386s = f9346f;
                this.f9368K = this.f9390w.offsetMonth(this.f9389v);
                GuliLog.tracePrintInfo(f9343c, "Offset Month : " + this.f9368K);
                this.f9384b = this.ae;
                this.ag = this.af;
            }
            this.f9366I = Integer.MAX_VALUE;
            this.f9367J = Integer.MAX_VALUE;
            this.f9393z = this.f9390w;
            m14141a(i, this.f9386s, false);
            this.ae.m8399d(false);
            this.af.m8399d(false);
            this.f9384b.m8556e();
            this.f9384b.m8555d(this.f9368K);
            this.f9384b.m8559f(this.f9368K);
            this.ax = true;
            this.ay = false;
        } else if (!this.f9365H && this.f9360C != 0) {
            this.f9365H = true;
            if (this.f9364G == f9350j) {
                this.f9364G = f9351k;
                this.ak.setEnabled(true);
            } else if (this.f9364G == f9351k) {
                this.f9364G = f9352l;
                this.al.setEnabled(false);
            }
            m14147a(this.f9384b, this.f9386s);
            Animator b = this.f9384b.m8547b(220, C0804t.m8825a(getActivity(), 185.0f), -1);
            b.setInterpolator(new AccelerateInterpolator());
            b.start();
            this.f9384b.postDelayed(new eW(this), b.getDuration() + 50);
        }
    }

    private void m14214r() {
        GuliLog.tracePrintInfo(f9343c, "Current Index : " + this.f9366I + " Last Index : " + this.f9367J);
        GuliLog.tracePrintInfo(f9343c, "Current Day : " + this.f9390w + " Last Day : " + this.f9393z);
    }

    private void m14217s() {
        m14157a(true, 0);
    }

    private void m14218t() {
        this.f9381X.clear();
        m14217s();
    }

    private void m14221u() {
        this.f9360C = this.f9358A.m15758b(this.f9362E);
        GuliLog.tracePrintInfo(f9343c, "WeightItemsCount : " + this.f9360C + ", WeightCurrentUserId : " + this.f9362E);
        if (this.f9360C == 0) {
            this.f9368K = 0;
            this.f9384b.m8552c();
            this.f9372O.m14823b();
            this.aj.setEnabled(false);
            this.ai.setEnabled(false);
            this.f9365H = false;
        } else {
            if (this.f9368K < (-(this.f9360C - 1))) {
                this.f9368K = -(this.f9360C - 1);
            }
            if (this.f9360C == f9356p) {
                WeightInfo f = this.f9358A.m15779f(this.f9362E);
                if (f != null) {
                    this.ae.m8544a(f.weight);
                }
            }
            if (this.f9362E == -1 && this.f9360C == f9356p) {
                this.aj.setEnabled(false);
                this.ai.setEnabled(false);
            } else {
                this.aj.setEnabled(true);
                this.ai.setEnabled(true);
            }
        }
        this.f9382Y.clear();
        m14172c(this.f9368K);
    }

//    public void m14227a(int i) {
//        GuliLog.tracePrintInfo(f9343c, "Realtime Steps Updated : " + i);
//        if (i > -1) {
//            Keeper.keepRealtimeStepsTimestamp(System.currentTimeMillis(), this.aF);
//            Keeper.keepRealtimeSteps(i, this.aF);
//            ChartData.m8731a().m8775a(i, this.aF);
//            if (this.f9388u != null && this.f9390w != null && this.f9388u.equals(this.f9390w) && getActivity() != null) {
//                getActivity().runOnUiThread(new eO(this));
//            }
//        }
//    }

    protected boolean m14228b() {
        return true;
    }

    class eK implements Runnable {
        final /* synthetic */ StatisticFragment f10048a;

        eK(StatisticFragment statisticFragment) {
            this.f10048a = statisticFragment;
        }

        public void run() {
            this.f10048a.f9384b.m8556e();
            this.f10048a.f9384b.m8555d(0);
        }
    }


    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        if (this.f9385r == f9346f) {
            ((ViewStub) getView().findViewById(R.id.chart_weight_layout)).inflate();
        } else {
            ((ViewStub) getView().findViewById(R.id.chart_stepsleep_layout)).inflate();
        }
        m14145a(getView());
        m14187f();
        this.f9376S = true;
        this.f9377T = true;
        m14143a(this.f9385r, true);
        m14165b(this.f9386s, true);
        AnimUtil.m8755a((ViewGroup) this.aq, (ViewGroup) this.ap);
        this.f9384b.setScrollable(true);
        this.f9384b.post(new eK(this));
        if (this.f9385r == f9346f) {
            this.ac.setVisibility(View.INVISIBLE);
            this.ad.setVisibility(View.VISIBLE);
            m14146a(this.f9361D, this.f9362E);
        }
        this.aG = getActivity().getIntent().getStringExtra(StatisticActivity.EXTRA_SYNC_ACTION);
        if (!TextUtils.isEmpty(this.aG) && this.f9385r == f9356p) {
            this.ac.setVisibility(View.GONE);
            View findViewById = getView().findViewById(R.id.sync);
            findViewById.setVisibility(View.VISIBLE);
            findViewById.setOnClickListener(this);
            this.aH = true;
        }
        EventBus.getDefault().register(this);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        if (i2 == -1 && intent != null) {
            int intExtra = intent.getIntExtra("UserId", -1);
            GuliLog.tracePrintInfo(f9343c, "Weight User Picked : " + intExtra);
            if (i == f9356p && this.f9362E != intExtra) {
                this.f9361D.m15385b(intExtra);
                m14182e(intExtra);
            }
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.share:
//                m14203l();
                break;
            case R.id.weight_report_dele_btn:
                m14198j();
                break;
            case R.id.mode_switch:
                if (this.f9385r != f9346f) {
                    m14207n();
                }
                break;
            case R.id.add_member:
                Intent intent = new Intent(getActivity(), RecordWeightActivity.class);
                intent.putExtra(WeightGoalSetActivity.f11178a, this.f9362E);
                getActivity().startActivity(intent);
                C0668a.m8128a(getActivity().getApplicationContext(), C0668a.gr, C0668a.gu);
                break;
            case R.id.sync:
                m14195i();
                break;
            case R.id.mode_statistic_zoom_in:
                m14213q();
                break;
            case R.id.weight_report_edit_btn:
                m14201k();
                break;
            case R.id.mode_statistic_zoom_out:
                m14209o();
                break;
            case R.id.user_picker:
                m14179d((int) f9356p);
                break;
            default:
        }
    }

    public void onCreate(Bundle bundle) {
        int i = -1;
        super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            this.f9385r = arguments.getInt(ChartData.KEY_MODE, f9356p);
            this.aE = arguments.getBoolean("FROM_PERSONINFO_FRAGMENT", false);
            this.aF = arguments.getInt(ChartData.KEY_SOURCE, C3843c.VDEVICE.m25103b());
            if (this.aF == C3843c.VDEVICE.m25103b()) {
                this.aF = DataManager.m12179a().m12239r();
            }
            GuliLog.tracePrintInfo(f9343c, "Mode : " + this.f9385r + ",DeviceType:" + this.aF);
            if (DeviceSource.hasBindSensorHub() && !DataManager.m12179a().m12231j()) {
                this.aC &= -2;
            }
        }
        this.f9386s = f9356p;
        this.f9387t = DataManager.m12179a();
//        this.f9388u = this.f9387t.m12219d(this.aF);
//        this.f9389v = this.f9387t.m12216c(this.aF);
//        this.f9391x = this.f9387t.m12202a(this.aF);
//        this.f9392y = this.f9387t.m12212b(this.aF);
        if (this.f9385r == f9346f) {
            this.f9358A = WeightInfoManager.getInstance();
            this.f9359B = UserInfoManager.getInstance();
            if (this.aE) {
                this.f9362E = -1;
            } else {
                int t = ChartData.m8731a().m8816t();
                if (t != 0) {
                    i = t;
                }
                this.f9362E = i;
            }
            this.f9360C = this.f9358A.m15758b(this.f9362E);
            this.f9391x = this.f9358A.m15783i();
            this.f9392y = this.f9358A.m15784j();
            this.f9389v = this.f9392y;
        }
        this.f9390w = this.f9389v;
        GuliLog.tracePrintInfo(f9343c, "Today : " + this.f9388u + " , StartDay : " + this.f9391x + " , StopDay : " + this.f9392y + " , CurrentDay : " + this.f9390w);
        this.f9378U = getString(R.string.dynamic_detail_sleep_title);
        this.f9379V = getString(R.string.dynamic_detail_step_title);
        this.f9380W = getString(R.string.dynamic_detail_weight_title);
        this.f9381X = new HashMap();
        this.f9382Y = new SparseArray();
        this.aB = Locale.getDefault().toString().startsWith(Locale.ENGLISH.toString());
        SportDay.onLocaleChanged(this.aB);
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.fragment_statistic, viewGroup, false);
        Resources resources = getActivity().getResources();
        this.ar = resources.getColor(R.color.bg_mode_sleep);
        this.as = resources.getColor(R.color.bg_mode_step);
        this.at = resources.getColor(R.color.bg_mode_weight);
        return inflate;
    }

    public void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }

    public void onDetach() {
        super.onDetach();
        this.ae.detach();
        if (this.af != null) {
            this.af.detach();
        }
    }

    public void onEvent(EventWeightWithUser eventWeightWithUser) {
        int i = eventWeightWithUser.uid;
        if (this.f9362E != i) {
            this.f9361D.m15385b(i);
            m14182e(i);
            return;
        }
        m14221u();
    }

    public void onEvent(EventUserPicked eventUserPicked) {
        GuliLog.tracePrintInfo(f9343c, "EventWeightUserPicked " + eventUserPicked.uid + ", Action : " + eventUserPicked.action);
        int i = eventUserPicked.uid;
        switch (eventUserPicked.action) {
            case 1 /*1*/:
                m14153a(this.f9363F, i);
            case 2 /*2*/:
                if (this.f9362E != i) {
                    this.f9361D.m15385b(i);
                    m14182e(i);
                }
            default:
        }
    }

    public void onEvent(EventWeightSyncedDevice eventWeightSyncedDevice) {
        GuliLog.tracePrintInfo(f9343c, "EventWeightSyncedDevice : " + eventWeightSyncedDevice.forceUpdate + ", " + eventWeightSyncedDevice.uid);
        if (eventWeightSyncedDevice.forceUpdate || eventWeightSyncedDevice.uid == this.f9362E) {
            m14221u();
        }
    }

    public void onEvent(EventWeightSyncedServer eventWeightSyncedServer) {
        GuliLog.tracePrintInfo(f9343c, "EventWeightSyncedServer : " + eventWeightSyncedServer.state);
        if (eventWeightSyncedServer.state == f9356p) {
            m14221u();
        }
    }

    public void onEvent(HwConnStatus hwConnStatus) {
        GuliLog.tracePrintInfo(f9343c, "On BLE Status Changed : " + hwConnStatus + ",type = " + hwConnStatus.m25399b());
        if (this.aF == hwConnStatus.m25399b().m25103b()) {
            if (this.aF == C3843c.SHOES.m25103b()) {
                if (hwConnStatus.m25402e()) {
                    this.aa.setText(getString(R.string.shoes_connecting));
                } else if (hwConnStatus.m25403f()) {
                    this.aa.setText(getString(R.string.shoes_alert_body_connect_failed));
                } else if (hwConnStatus.m25405h()) {
                    this.aa.setText(getString(R.string.shoes_connect_failed));
                }
            } else if (hwConnStatus.m25408k()) {
                GuliLog.tracePrintInfo(f9343c, "Enable Realtime Steps : " + isVisible());
                if (m14174c()) {
//                    RtStep.enableRtSteps(getActivity(), this.aF, isVisible(), this);
                }
            }
        }
    }

    public void onEvent(HwSyncDataStatus hwSyncDataStatus) {
        GuliLog.tracePrintInfo(f9343c, "On BLE Status Changed : " + hwSyncDataStatus + ",type = " + hwSyncDataStatus.m25421h());
        if (this.aF == hwSyncDataStatus.m25421h().m25103b()) {
            if (hwSyncDataStatus.m25417d() && isAdded()) {
                GuliLog.tracePrintInfo(f9343c, "Enable Realtime Steps : " + isVisible());
                if (m14174c()) {
//                    RtStep.enableRtSteps(getActivity(), this.aF, isVisible(), this);
                }
            }
            if (isVisible() && this.f9385r != f9346f) {
                m14154a(hwSyncDataStatus);
                if (hwSyncDataStatus.m25417d() && hwSyncDataStatus.m25420g()) {
                    m14218t();
                }
            }
        }
    }

    public void onPause() {
        super.onPause();
        GuliLog.tracePrintInfo(f9343c, "Enable Realtime Steps : false");
        if (m14174c()) {
//            RtStep.enableRtSteps(getActivity(), this.aF, false, this);
        }
        C0668a.m8141b(C0668a.f3562e);
    }

    public void onResume() {
        super.onResume();
        if (this.aF == C3843c.SHOES.m25103b()) {
            m14154a(new HwSyncDataStatus(C3843c.SHOES));
        } else {
//            m14154a(C0639F.f3447b);
        }
        GuliLog.tracePrintInfo(f9343c, "Enable Realtime Steps : true");
        if (m14174c()) {
//            RtStep.enableRtSteps(getActivity(), this.aF, true, this);
        }
        C0668a.m8133a(C0668a.f3562e);
    }

    public void onStop() {
        super.onStop();
//        if (this.aD != null) {
//            this.aD.m13249a();
//            this.aD = null;
//        }
    }
}
